<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>


  <% try{ %>
   
<form id="zhifu" action="" method="post" >
<!-- cashierDesk!toOrderPay.do -->
<div class="dialog open">
    <div class="dialog-head">
      <span class="close rotate-hover"></span>
      <strong>
      <s:if test="#memberStatus!=0">
      ${tam.memberName }(${tam.memberPhone })
      
      </s:if>
       确认收银</strong>
    </div>
    <div class="dialog-body line pay-order-confirm">
        <div class="x12 over-auto" style= 'height: 380px;'>
        
        <input type="hidden" name="memberId" value="${tam.id.memberId }" />
        
          <%--  <input type="hidden" name="pdata[t_member_id]" value="154895">
            <input type="hidden" name="pdata[t_member_mobile]" value="13444444444">
            <input type="hidden" name="pdata[s_b_order_id]" value="">
             <s:iterator value="#taogList" var="obj" status="sta">
                <input type="hidden" name="goodsId[${sta.count }]" value="${obg.goodsId }">
                <input type="hidden" name="goodsPrice[${sta.count }]" value="${obj.goodsPrice }">
                <input type="hidden" name="goodsPayPrice[${sta.count }]" value="${obj.goodsPayPrice }">
                <input type="hidden" name="goodsBuyNum[${sta.count }]" value="${obj.goodsNum }">
            </s:iterator> --%>
            <div class="x12 form-group">
                <div class="x3 text-right padding-right height-big">
                    <label><strong>应付</strong></label>
                </div>
                <div class="x5 padding-large-right">
                    <div class="input-group">
                        <input class="input text-large" type="text" id="original_money" name="orderMoney" value="${tao.orderAmount }" readonly="true">
                        <span class="addon">元</span>
                    </div>
                </div>
            </div>
            <div class="x12 form-group">
                <div class="x3 text-right padding-right height-big">
                    <label><span class="text-dot">*</span><strong>立减</strong></label>
                </div>
                <div class="x5 padding-large-right">
                    <div class="input-group">
                        <input class="input" type="text" id="discount" name="discount" value="0.0" onkeyup="javascrpt:sumPaymoney();">
                        <span class="addon">元</span>
                    </div>
                </div>
                <div class="x8 input-note x3-move">

                </div>
            </div>
            <div class="x12 form-group">
                <div class="x3 text-right padding-right height-big">
                    <label><strong>实收</strong></label>
                </div>
                <div class="x5 padding-large-right">
                    <div class="input-group">
                        <input class="input text-large text-dot" type="text" id="money_num" name="moneyNum" value="" readonly onchange="javascrpt:stayPaymoney();">
                        <span class="addon">元</span>
                    </div>
                </div>
                <div class="x8 input-note x3-move">

                </div>
            </div>
             <s:if test="#memberStatus!=0">
             <div class="x12 form-group">
                <div class="x3 text-right padding-right height-big">
                    <label><strong>赠送积分</strong></label>
                </div>
                <div class="x5 padding-large-right">
                    <div class="input-group">
                        <input class="input" tabindex="3" type="text" id="givenpoints" name="integral"  value="${integral }" readonly />
                        <span class="addon">分</span>
                    </div>
                </div>
                <div class="x8 input-note x3-move">
                    <span class="text-dot"><strong></strong></span><br>
               <!--      赠送积分=待付金额×积分规则(消费时设定值)×会员级别积分倍率<br>
                    (如果使用积分抵现，本笔交易不会赠送积分)            -->     </div>
            </div>
            </s:if>
           <%--  <div class="x12 form-group ">
                <div class="x3 text-right padding-right height-big">
                    <label><strong>参与提成员工</strong></label>
                </div>
                <div class="x9 padding-large-right">
                    <div class="x12 margin-bottom">
                        <button class="button bg-sub button-small" type="button" onclick="javascript:$showdialogs($(this));" data-url="http://shop.hookwin.com/index.php/user/Cutlevel_user/xform" data-toggle="click" data-mask="1" data-width="520px"><span class="icon-plus"></span></button>
                    </div>
                    <div class="x12" id="cutdetail-user">
                    </div>
                </div>
            </div> --%>
                        <div class="x12 form-group">
                <div class="x3 text-right padding-right height-big"><strong>备注</strong></div>
                    <div class="x5 padding-large-right">
                        <textarea class="input" name="note"></textarea>
                    </div>
            </div>
        </div>
        <div class="x12 text-center">
            <input type="hidden" name="orderSn" value="${tao.orderSn }">
            <input type="hidden" name="pay_method" id="pay_method" value="" data-validate="required:必填">
                   <%--          <div class="x3 padding-right">
                <span class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" onclick="alert('weixin');" pay-method="4" title="微信支付">微信支付</span>
                </div> --%>
                            <div class="x3 padding-right">
                <span class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" onclick="zhifubao(this);" pay-method="5" title="支付宝">支付宝</span>
                </div>
                            <!-- <div class="x3 padding-right">
                <button class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" pay-method="3" title="银联卡">银联卡</button>
                </div> -->
                            <div class="x3 padding-right">
                <span class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" onclick="xianjin(this);" pay-method="2" title="现金">现金</span>
                </div>
                 <s:if test="#memberStatus!=0">
                            <!-- <div class="x3 padding-right">
                <button class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" pay-method="9" title="优惠券">优惠券</button>
                </div> -->
                           <!--  <div class="x3 padding-right">
                <button class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" pay-method="6" title="积分抵现">积分抵现</button>
                </div> -->
                            <div class="x3 padding-right">
                <button class="button button-big button-block bg-green margin pay-method cashier-pay-btn" type="button" onclick="memberCard(this)" pay-method="1" title="会员卡余额">会员卡余额</button>
                </div>
                </s:if>
                    </div>
    </div>
    <div class="dialog-foot">
      <button class="button dialog-close" type="button">取消</button>
    </div>
  </div>
</form>
<script type="text/javascript">
/*** 手动修改优惠金额 ***/

$(function(){
	sumPaymoney();
});

 function status(){
	if(discount>original_money){
       discount = 0;
        $discount.val(0);
        $.Showmsg("输入金额不能大于应收金额，请重新输入！");
			setTimeout(function() {
                            $.Hidemsg();
    				    }, 3500);
    }
    return;
} 

function sumPaymoney(){
    var $original_money = $('#original_money'); //原金额
    var $discount = $('#discount');//优惠金额
    var discount = $discount.val();
    var original_money = $original_money.val();
    if(discount==""||isNaN(discount)){
        discount = 0;
        $discount.val(0);
    }
     if(discount>original_money){
       discount = 0;
        $discount.val(0);
        $.Showmsg("输入金额不能大于应收金额，请重新输入！");
			 setTimeout(function() {
                            $.Hidemsg();
    				    }, 3500); 
    } 
    if(original_money==""||isNaN(original_money)){
        original_money = 0;
        $original_money.val(0);
    }
    var $money_num = $('#money_num');//侍付款金额
    var money = (parseFloat(original_money)-parseFloat(discount)).toFixed(2);
    $money_num.val(money);
   // sumPoints();
}
function stayPaymoney(){
    var $original_money = $('#original_money'); //原金额
    var $discount = $('#discount');//优惠金额
    var $money_num = $('#money_num');//待收金额
    var money_num = $money_num.val();
    var original_money = $original_money.val();
    if(money_num==""||isNaN(money_num)){
        money_num = 0;
        $money_num.val(0);
    }
    if(original_money==""||isNaN(original_money)){
        original_money = 0;
        $original_money.val(0);
    }
    var $money_num = $('#money_num');//侍付款金额
    var money = (parseFloat(original_money)-parseFloat(money_num)).toFixed(2);
    $discount.val(money);
    //sumPoints();
}
/** 如果是手动输入，就计算应得的积分
* (待付金额/设定值)×会员级别积分倍率。
**/
/* function sumPoints(){
    var xthis = $('#money_num');
    var $givenpoints = $('#givenpoints');
    var point = 0;
    //待付金额×设定值×会员级别积分倍率
    if(parseFloat($givenpoints.attr('data-cfg-points-xf'))>0){
        point = (parseFloat($(xthis).val())/parseFloat($givenpoints.attr('data-cfg-points-xf')))*parseFloat($givenpoints.attr('data-level-point'));
    }
    $givenpoints.val(parseInt(point));
} */

   function zhifubao(_this){
   		var pay_method = $(_this).attr("pay-method");
   		$("#zhifu").attr("action","cashierDesk!toOrderPay.do?pay_method="+pay_method);
   		$("#zhifu").submit;
   }

	function xianjin(_this){
   		
	   	//将数据拿去后台生成一个订单，
	    var $form = $("#zhifu");
	    var $post_data = $form.serializeArray();
	   	//打开一个浮层来显示
	    var b = {};
	    b['data-toggle']='click';
	    b['data-url']="cashierDesk!toXianJin.do";
	    b['data-mask']='1';
	    b['data-postdata']=$post_data;
	    b['data-width']='800px';
	    var $win = $showdialogs($(b));
	}
	
	function memberCard(_this){
		//将数据拿去后台生成一个订单，
	    var $form = $("#zhifu");
	    var $post_data = $form.serializeArray();
	    //打开一个浮层来显示
	    var b = {};
	    b['data-toggle']='click';
	    b['data-url']="cashierDesk!toMemberCard.do";
	    b['data-mask']='1';
	    b['data-postdata']=$post_data;
	    b['data-width']='800px';
	    var $win = $showdialogs($(b));
	}
	
	
</script>
<%}catch(Exception e){
     e.printStackTrace();
  }
 %>
